<template>
  <div class="container tree-list-layout">
    <data-view
      propViewKey="device_benefit_settings"
      propViewForm="device/benefit/settings/detail.vue"
      :propIsTdesign="true"
      :propOnlyQueryAll="true"
      :propShowRadiobox="true"
      ref="dvLeft"
      class="box-left"
      style="width: 500px !important;"
      @current-change="leftCurrentChange"
    />

    <data-view
      propViewKey="device_benefit_setmap"
      propViewForm="device/benefit/setmap/detail.vue"
      :propIsTdesign="true"
      :propInitData="leftSelect"
      ref="dvRight"
      :propAutoFetchData="false"
      class="box-right"
      style="width: calc(100% - 500px) !important"
      :propBeforeClick="propBeforeClickDtl"
    />
  </div>
<!--  <div class="container">
    <data-view
      propViewKey="device_benefit_setmap"
      propViewForm="device/benefit/setmap/detail.vue"
      :propIsTdesign="true"
      ref="dataView"
      :propAutoFetchData="false"
    />

     <treeOffice @click="handleTreeClick" ref="treeOffice"  class="box-left"/>
    <data-view
      ref="dataView"
      propViewKey="sys_office"
      propViewForm="sys/office/detail.vue"
      :propInitData="selectedTreeNode"
      @after-save="handleAfterSave"
      @after-delete="handleAfterDelete"
      @extra-button-click="extraButtonClick"
      :propIsTdesign="true"
      class="box-right"
    />

  </div>-->
</template>

<script>
import treeOffice from "@/components/custom/bus/treeOffice.vue";

export default {
  desc: '效益分析系统对接设置-列表',
  props: [],
  mounted() {
    this.loadDtl()
  },

  data() {
    return {
      leftSelect: {}
    }
  },
  computed: {
  },
  components: {treeOffice},
  methods: {
    loadDtl() {
      let wrapper = this.$newWrapper()
      this.$refs.dvLeft.setQueryWrapper(wrapper)
    },
    loaMap() {
      let wrapper = this.$newWrapper()
      wrapper.eq('set_id', this.strings.defaultIfBlank(this.leftSelect.id, '-1'))
      this.$refs.dvRight.setQueryWrapper(wrapper)
    },
    // 列表按钮点击前操作
    propBeforeClickDtl(button, formData , rowData, that) {
      //列表添加按钮
      if (button.key == this.constCommon.btnKeyMap.table.add) {
        if (!this.leftSelect || !this.leftSelect.id) {
          this.utilMessage.warning('请选择左侧需要操作的设备')
          return false
        }
      }
      return true
    },

    leftCurrentChange(param) {
      console.log('leftCurrentChange', param)
      this.leftSelect = param.row.row
      this.loaMap()
    }
  }
}
</script>
